const search = {
  state: {
    searchKey: undefined,
    searchKeyStatus: false,
    category: undefined,
    categoryStatus: false
  },
  mutations: {
    // 搜索值
    SET_SEARCHKEY: (state, data) => {
      state.searchKey = data || undefined;
      // 更新状态触发搜索
      state.searchKeyStatus = !state.searchKeyStatus;
    },
    // 选择品种
    SET_CATEGORY: (state, data) => {
      state.category = data;
      state.categoryStatus = !state.categoryStatus;
    }
  },
  actions: {
    // 更新搜索值
    updateSearchKey: ({ commit }, data) => {
      commit("SET_SEARCHKEY", data);
    },
    // 选择分类品种
    updateCategory: ({ commit }, data) => {
      commit("SET_CATEGORY", data);
    }
  }
};

export default search;
